const fs = require('fs');

//获得文件名
let  files = fs.readdirSync('./code');

files.forEach(value => {
   //拆分名字
   let names = value.split('_');
   let [num,name] = names;
   console.log(names);
   if (Number(num) < 10) {
       num = Number(num);
   }
   let NewName = num + '-' + name;
   fs.rename('./code/'+ value,'./code/' + NewName,err => {
       if (err) {
           console.log('操作失败');
           console.log(err);
           return;
       }
       console.log('操作成功');
   });
});